#pragma once

#include <map>
#include "CLocalObject.h"
#include "CLComList.h"
#include "CDataFile.h"
#include "CLComValue.h"
#include "CLComLibrarys_global.h"
//CLCOMLIBRARYS_EXPORT

class CLCOMLIBRARYS_EXPORT CLComSequence :public CLocalObject
{
public:
    CLComSequence(CLComString filename);
    ~CLComSequence();

    void LoadSequence();
public:
    static void Copy(CLComSequence* pdst, const CLComSequence* psrc);

public:
	virtual bool GoBack();
	virtual bool GoNext();
public:
	virtual bool GoBack(int nIndex);
	virtual bool GoNext(int nIndex);
public:
	virtual bool BackUp(CRecordItem& recordinfo);
public:
	void Update();
public:
	void ClearBackup();
	void Save2File(FILE* file);
	void ClearKeys();
    void LoadFromFile(CLComString fileName);
public:
    void AddItem(CLComString id);
    int AddItemBack(CLComString id, CLComValue item, CLComString preId);
    CLComString GetFirstItem()const;
    CLComString GetNextItem(CLComString currentid)const;
    CLComString GetPrevItem(CLComString currentid)const;

    void DelItem(CLComString id);
public:
    int MoveUP(CLComString currentid);
    int MoveDown(CLComString currentid);
    void Move2Next(CLComString frontID, CLComString currentid);
    void Move2Front(CLComString nextID, CLComString currentid);
public:
    void MoveUP(CLComString startID, CLComString endID);
    void MoveDown(CLComString startID, CLComString endID);
    void Move2Next(CLComString frontID, CLComString startID, CLComString endID);
    void Move2Front(CLComString nextID, CLComString startID, CLComString endID);

private:
	void SaveSequence();
    void AddItemNoSave(CLComString id);
private:
	CDataFile*					m_pDataFile;
    CLComList					m_idlist;
};

